package fitness

import (
	"organoid_public/domain/fitness/service"
	"organoid_public/global"
)

// 主要是写明领域服务的依赖关系
type UseCase struct {
	MerchantSvc service.MerchantServiceInterface
	ProductSvc  service.ProductServiceInterface
	OpenAppSvc  service.OpenAppServiceInterface
}

func NewUseCase(MerchantSvc service.MerchantServiceInterface, ProductSvc service.ProductServiceInterface, OpenAppSvc service.OpenAppServiceInterface) *UseCase {
	return &UseCase{MerchantSvc: MerchantSvc, ProductSvc: ProductSvc, OpenAppSvc: OpenAppSvc}
}

func wireService() (*UseCase, error) {
	defaultDb := global.GormDb.GetDb("ali_fitness_pay")
	log := global.Log
	uc, cleanUp, err := WireApp(defaultDb, log)
	defer cleanUp()
	if err != nil {
		return nil, err
	}
	return uc, err
}

// 发现领域服务
func Service() (*UseCase, error) {
	return wireService()
}
